Typically, when a TCP/IP application wants to send information, the information travels down the protocol layers to IP where the information is encapsulated in an IP datagram. The IP datagram then proceeds down to the data link layer of the device's physical network for transmission to the next hop, on the way to the IP destination. However, operating systems typically support a loopback interface that allows for a client and a server on the same host machine to communicate with each other using TCP/IP. In this case, changing the IP address of the destination server to the loopback address results in a TCP loopback connection being established, and information is exchanged between a client and server on the same host machine.
In some operating systems, when using a TCP/IP loopback connection, although the transport layer detects that the destination of the information is local, the operating system performs complete processing of the data in the transport and network layers prior to sending the IP datagram back to itself. In effect, the operating system treats the IP datagram as if its coming from the network. Thus, multiple layers of protocol processing and logic are applied to the loopback traffic carrying data. Even though the stack is aware that the endpoints are local to the host, the stack pretends that the data originated externally. In some cases, treating a local IP datagram as if its coming from the network results in unnecessary processing such as inspecting, packetizing, and corresponding with network protocols.